package com.kaifamiao.www.demo.Do26;

public class Person {
    String name;
    char gender;
    int age;
    boolean isMarry;


    public void show(String[] args) {
        System.out.println(name + gender + "年龄" + age + isMarry);
    }

    //性别不等，年龄男 >=22,女>=20,  isMarry == false
    public boolean canMarry(Person person) {
        if (this.gender == person.gender) {
            return false;
        }
        if (this.gender == '男' && this.age >= 22 && person.age >= 20 && this.isMarry == false && person.isMarry == false) {
            return true;
        }
        if (this.gender == '女' && this.age >= 20 && person.age >= 22 && this.isMarry == false && person.isMarry == false) {
            return true;
        }
        return false;
    }
}